package d1_com.itheima.collection;

import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;

public class TreeSetDemo {
    public static void main(String[] args) {
        Set<Integer> set = new TreeSet<>();
        set.add(666);
        set.add(555);
        set.add(333);
        set.add(444);
        set.add(222);
        System.out.println(set);

        Set<Student> treesets = new TreeSet<>(( o1, o2)->Double.compare(o1.getAge(),o2.getAge()));
        treesets.add(new Student("老八",20));
        treesets.add(new Student("老七",21));
        treesets.add(new Student("老八",19));
        treesets.add(new Student("老六",22));
        System.out.println(treesets);
    }
}
